Skip to content

fix(mybatis): correcting the description of namespace in the mybatis#2858

Merged
Snailclimb merged 1 commit into
Snailclimb:mainfrom
bengbengbalabalabeng:main
May 28, 2026
Merged

fix(mybatis): correcting the description of namespace in the mybatis#2858
Snailclimb merged 1 commit into
Snailclimb:mainfrom
bengbengbalabalabeng:main

Conversation

@bengbengbalabalabeng
Copy link
Copy Markdown
Contributor

修改

题目:MyBatis 的 xml 映射文件中,不同的 xml 映射文件,id 是否可以重复? 的答案中关于 namespace 不是必须的描述是错误的。(参考 MyBatis XMLMapperBuilder#configurationElement 源码)

private void configurationElement(XNode context) {
    try {
      String namespace = context.getStringAttribute("namespace");
      if (namespace == null || namespace.isEmpty()) {
        // 如果 namespace 不存在会直接抛出异常
        throw new BuilderException("Mapper's namespace cannot be empty");
      }
      
      // ... ...
    } catch (Exception e) {
      throw new BuilderException("Error parsing Mapper XML. The XML location is '" + resource + "'. Cause: " + e, e);
    }
  }

@Snailclimb Snailclimb merged commit 1a9a92d into Snailclimb:main May 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants